﻿{include file="public/header"}
<title>店长列表</title>
</head>
<body>
<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i> 首页
    <span class="c-gray en">&gt;</span> 店长管理
    <span class="c-gray en">&gt;</span> 店长列表
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div class="page-container">
    <form method="get">
        <div class="ch-c">
            <div class="ch-form-row">
                <p>注册时间:</p>
                <input type="text" name="start_time" id="countTimestart" onfocus="selecttime(1)" readonly
                value="<?php echo isset($data['start_time'])?$data['start_time']:''?>">
                <b>-</b>
                <input type="text" name="end_time" id="countTimeend" onfocus="selecttime(2)" readonly
                value="<?php echo isset($data['end_time'])?$data['end_time']:''?>">
            </div>
            <input type="text" name="mobile" placeholder=" 账号" class="ch-form-assignor" value="<?php echo isset($data['mobile'])?$data['mobile']:''?>">
            <input type="text" name="username" placeholder=" 昵称" class="ch-form-assignor" value="<?php echo isset($data['username'])?$data['username']:''?>">
            <button class="btn btn-success" type="submit"><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
        </div>
    </form>
    <div class="mt-20">
        <div class="title-border">
            <div class="flex2 screen-phone">序号</div>
            <div class="flex3">店长昵称</div>
            <div class="flex3">电话</div>
            <div class="flex2 screen-phone">店铺</div>
            <div class="flex3 screen-phone">编号</div>
            <div class="flex4">店铺地址</div>
            <div class="flex1 screen-phone">性别</div>
            <!-- <div class="flex3 screen-phone">邮箱</div> -->
            <div class="flex3 screen-phone">注册时间</div>
            <div class="flex3 screen-phone">登录时间</div>
            <div class="flex1 screen-phone">状态</div>
            <div class="flex2 screen-phone">当前状态</div>
            <div class="flex5">操作</div>
        </div>
        {volist name='list' id='vo'}
        <div class="content-border">
                <div class="flex2 screen-phone">{$vo.user_id}</div>
                <div class="flex3">{$vo.username}</div>
                <div class="flex3">{$vo.mobile}</div>
                <div class="flex2 screen-phone">{$vo.store_name}</div>
                <div class="flex3 screen-phone">{$vo.number}</div>
                <div class="flex4">{$vo['province'].$vo['city'].$vo['area'].$vo['addres']}</div>
                <div class="flex1 screen-phone">
                    {if condition="$vo.sex == 0"} 保密
                    {elseif condition="$vo.sex == 1"/}男
                    {elseif condition="$vo.sex == 2"/}女
                    {/if}
                </div>
               <!-- <div class="flex3 screen-phone">{$vo.email}</div>-->
                <div class="flex3 screen-phone">{:date('Y-m-d H:i:s',$vo.created_time)}</div>
                <div class="flex3 screen-phone">{:date('Y-m-d H:i:s',$vo.last_login_time)}</div>
                <div class="flex1 screen-phone">
                        {if condition="$vo.status == 0"} 正常
                        {elseif condition="$vo.status == 1"/}禁用
                        {elseif condition="$vo.status == 2"/}删除
                        {/if}
                </div>
                <div class="flex2 screen-phone">
                        {if condition="$vo.state == 0"} 离线
                        {elseif condition="$vo.state == 1"/}在线
                        {/if}
                </div>
                <div class="flex5 screen-pc">
                    <a class="ch-button ch-blue more" href="javascript:;" title="查看更多">查看更多</a>
                </div>
                <div class="flex5 screen-phone">
                        {if condition="$vo.status == 0"}
                        <a style="text-decoration:none" class="ch-button ch-wathet cha" data-id="{$vo.user_id}" data-status="1" href="javascript:;" title="查看位置">查看位置</a>
                        <a style="text-decoration:none" class="ch-button ch-red disable" data-id="{$vo.user_id}" data-status="1" href="javascript:;" title="禁用">禁用</a>


                        <?php if($vo['state']==1){ ?>
                        <a style="text-decoration:none" class="ch-button ch-gray qi" data-id="{$vo.user_id}" data-status="0" href="javascript:;" title="下线">下线</a>

                    <?php }else{ ?>
                        <a style="text-decoration:none" class="ch-button ch-blue qi" data-id="{$vo.user_id}" data-status="1" href="javascript:;" title="上线">上线</a>

                        <?php } ?>
                    <?php if($vo['reserve']==1){ ?>
                    <a style="text-decoration:none" class="ch-button ch-red she" data-id="{$vo.user_id}" data-status="2" href="javascript:;" title="禁用">设为储备店长</a>
                        <?php }else{ ?>

                    <a style="text-decoration:none" class="ch-button ch-red she" data-id="{$vo.user_id}" data-status="1" href="javascript:;" title="禁用">设为店长</a>
                        <?php } ?>
                        <a style="text-decoration:none" class="ch-button ch-blue edit" data-id="{$vo.user_id}" href="javascript:;" title="编辑">编辑</a>
                        <a style="text-decoration:none" class="ch-button ch-yellow reset" data-id="{$vo.user_id}" href="javascript:;" title="重置密码">重置密码</a>
                        {/if}
    
                        {if condition="$vo.status == 1"}
                        <a style="text-decoration:none" class="ch-button ch-yellow disable" data-id="{$vo.user_id}" data-status="0" href="javascript:;" title="启用">启用</a>
                        <a style="text-decoration:none" class="ch-button ch-blue edit" data-id="{$vo.user_id}" href="javascript:;" title="编辑">编辑</a>
                        {/if}
    
                        <a style="text-decoration:none" class="ch-button ch-red del" data-id="{$vo.user_id}" href="javascript:;" title="删除">删除</a>    
                </div>
        </div>
        {/volist}
        <div class="pages" style="float: right">{$list->render()}</div>
        <div class="ch-more">
            <div class="ch-more-box">
                <div class="ch-more-top">
                    <div class="ch-more-off"></div>
                </div>
                <div class="ch-more-tark">
                    <div class="ch-more-content">
                        
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

{include file="public/footer"}
<script type="text/javascript">
    function selecttime(flag) {
        if (flag == 1) {
            var endTime = $("#countTimeend").val();
            if (endTime != "") {
                WdatePicker({dateFmt: 'yyyy-MM-dd', maxDate: endTime})
            } else {
                WdatePicker({dateFmt: 'yyyy-MM-dd'})
            }
        } else {
            var startTime = $("#countTimestart").val();
            if (startTime != "") {
                WdatePicker({dateFmt: 'yyyy-MM-dd', minDate: startTime})
            } else {
                WdatePicker({dateFmt: 'yyyy-MM-dd'})
            }
        }
    }

    $('.page-container').on('click','.edit',function () {
        var winWidth = $(window).width();
        var areaWidth = "";
        var areaHeight = "";
        if( winWidth > 768 ){
            areaWidth = "600px"
            areaHeight = "550px"
        } else {
            areaWidth = '100%'
            areaHeight = '100%'
        }
        var id=$(this).attr('data-id');
        var src="{:Url('index/user/edit')}";
        layer.open({
            type: 2,
            area: [areaWidth, areaHeight],
            title: '编辑',
            content: src+'?user_id='+id
        });
    });
    $('.page-container').on('click','.cha',function () {
        var src="{:Url('index/user/cha')}";
        var id=$(this).attr('data-id');
            $.ajax({
                type: 'POST',
                url: src,
                dataType: 'json',
                data:{user_id:id},
                success: function (data) {
                    var res=JSON.parse(data);
                    if(res.code==200){
                        var src="{:Url('index/user/map')}";
                        var index = layer.open({
                            type: 2,
                            fix: false,
                            area: ['20%'],
                            title: '查看',
                            content: src+'?user_id='+res.data.id
                        });
                        layer.full(index);
                    }else{
                        layer.msg(res.msg,{icon: 5,time:1000});
                    }

                },
                error: function (data) {
                    console.log(data.msg);
                },
            });

        });



    /**
     * 禁用/启用
     */
    $('.page-container').on('click','.disable',function () {
        var id=$(this).attr('data-id');
        var status=$(this).attr('data-status');
        var obj={};
        obj.user_id=id;
        obj.status=status;
        var str='确认要启用该用户吗？';
        if(status==1){
            str='确认要禁用该用户吗？';
        }
        var src="{:Url('index/user/disable')}";
        layer.confirm(str, function (index) {
            $.ajax({
                type: 'POST',
                url: src,
                dataType: 'json',
                data: obj,
                success: function (res) {
                    if(res.code==200){
                        layer.msg(res.msg, {icon: 1, time: 2000}, function () {
                            setTimeout("window.location.reload()", 1);
                        });
                    }else{
                        layer.msg(res.msg,{icon: 5,time:3000});
                    }

                },
                error: function (data) {
                    console.log(data.msg);
                },
            });
        });
    });
    /**
     * 储备店长
     */
    $('.page-container').on('click','.she',function () {
        var id=$(this).attr('data-id');
        var status=$(this).attr('data-status');
        var obj={};
        obj.user_id=id;
        obj.status=status;
        var str='确认要设定么？';
        if(status==1){
            str='确认要修改该用户吗？';
        }
        var src="{:Url('index/user/she')}";
        layer.confirm(str, function (index) {
            $.ajax({
                type: 'POST',
                url: src,
                dataType: 'json',
                data: obj,
                success: function (res) {
                    if(res.code==200){
                        layer.msg(res.msg, {icon: 1, time: 2000}, function () {
                            setTimeout("window.location.reload()", 1);
                        });
                    }else{
                        layer.msg(res.msg,{icon: 5,time:3000});
                    }

                },
                error: function (data) {
                    console.log(data.msg);
                },
            });
        });
    });

    /**
     * 删除
     */
     $('.page-container').on('click','.del',function () {
        var id=$(this).attr('data-id');
        var obj={};
        obj.user_id=id;
        var src="{:Url('index/user/del')}";
        layer.confirm('确认要删除吗？', function (index) {
            $.ajax({
                type: 'POST',
                url: src,
                dataType: 'json',
                data: obj,
                success: function (data) {
                    var res=JSON.parse(data);
                    if(res.code==200){
                        layer.msg(res.msg, {icon: 1, time: 2000}, function () {
                            setTimeout("window.location.reload()", 1);
                        });
                    }else{
                        layer.msg(res.msg,{icon: 5,time:1000});
                    }

                },
                error: function (data) {
                    console.log(data.msg);
                },
            });
        });
    });
    /**
     * 启用
     */
    $('.page-container').on('click','.qi',function () {
        var id=$(this).attr('data-id');
        var status=$(this).attr('data-status');
        var obj={};
        obj.user_id=id;
        obj.status=status;
        var str='确认要更改该用户状态吗？';
        var src="{:Url('index/user/qi')}";
        layer.confirm(str, function (index) {
            $.ajax({
                type: 'POST',
                url: src,
                dataType: 'json',
                data: obj,
                success: function (res) {
                    if(res.code==200){
                        layer.msg(res.msg, {icon: 1, time: 2000}, function () {
                            setTimeout("window.location.reload()", 1);
                        });
                    }else{
                        layer.msg(res.msg,{icon: 5,time:3000});
                    }

                },
                error: function (data) {
                    console.log(data.msg);
                },
            });
        });
    });

    /**
     * 重置密码
     */
     $('.page-container').on('click','.reset',function () {
        var id=$(this).attr('data-id');
        var obj={};
        obj.user_id=id;
        var src="{:Url('index/user/reset')}";
        layer.confirm('确认要重置该用户的密码吗？', function (index) {
            $.ajax({
                type: 'POST',
                url: src,
                dataType: 'json',
                data: obj,
                success: function (data) {
                    var res=JSON.parse(data);
                    console.log(res);
                    if(res.code==200){
                        layer.msg(res.msg, {icon: 1, time: 2000});
                    }else{
                        layer.msg(res.msg,{icon: 5,time:1000});
                    }

                },
                error: function (data) {
                    console.log(data.msg);
                },
            });
        });
    });
</script>
</body>
</html>
